package com.usst.biz;

import java.io.InputStream;

import javax.xml.XMLConstants;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import com.usst.handle.CommentHandler;
import com.usst.handle.CommentHandler5;
import com.usst.service.CommentService;
import com.usst.service.PostAnswerService;
import com.usst.service.PostService;

@Controller
public class CommentDataBiz5 {

	@Autowired
	private PostService postService;
	
	@Autowired
	private PostAnswerService postAnswerService;
	
	@Autowired
	private CommentService commentService;
	
	public void readXml(InputStream inStream) {
		try {
			SAXParserFactory spf = SAXParserFactory.newInstance(); 
			spf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, false);
			SAXParser saxParser = spf.newSAXParser(); // 创建解析器        
			
			CommentHandler5 handler = new CommentHandler5(postService, postAnswerService, commentService);      
			saxParser.parse(inStream, handler);        
			inStream.close();
			
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
	}
	
}
